package com.ssy.lingxi.member.merchant.entity;

import com.fasterxml.jackson.annotation.JsonBackReference;
import com.ssy.lingxi.member.merchant.handler.converter.JpaJsonToAuthBOConverter;
import com.ssy.lingxi.member.merchant.model.bo.AuthBO;

import javax.persistence.*;
import java.io.Serializable;
import java.util.List;

/**
 * 会员菜单权限
 * @author 万宁
 * @version 2.0.0
 * @date 2021-05-13
 */
@Entity
@Table(schema = "public", name = "ms_mc_member_auth", indexes = {@Index(name="ms_mc_member_auth_member_id_idx", columnList = "member_id")})
public class MemberAuthDO implements Serializable {
    private static final long serialVersionUID = 738815595041687264L;

    /**
     * id
     */
    @Id
    @GeneratedValue(strategy= GenerationType.SEQUENCE, generator="member_auth_seq")
    @SequenceGenerator(sequenceName="ms_mc_member_auth_seq", name="member_auth_seq",allocationSize = 1)
    private Long id;

    /**
     * 一对一双向关联会员
     */
    @JsonBackReference
    @OneToOne(cascade = CascadeType.DETACH, fetch = FetchType.LAZY)
    @JoinColumn(name="member_id", referencedColumnName="id")
    private MemberDO member;

    /**
     * 权限
     */
    @Convert(converter = JpaJsonToAuthBOConverter.class)
    @Column(columnDefinition = "jsonb")
    private List<AuthBO> auth;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public MemberDO getMember() {
        return member;
    }

    public void setMember(MemberDO member) {
        this.member = member;
    }

    public List<AuthBO> getAuth() {
        return auth;
    }

    public void setAuth(List<AuthBO> auth) {
        this.auth = auth;
    }
}
